package worktest;

import java.io.IOException;
import java.io.StringReader;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.xml.sax.InputSource;

public class GetAwardChanceUtil {

	
	public static String parseXml(String responseXML){
		StringReader read = new StringReader(responseXML);
        InputSource source = new InputSource(read);
        SAXBuilder sb = new SAXBuilder();
		try {
			Document doc = sb.build(source);
			Element root = doc.getRootElement();
			String hRet = root.getChild("hRet").getText();
			return hRet;
		} catch (JDOMException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return "x";
	}
	
	public static void main(String[] args) throws Exception {
		String respXml = "<OrderGatherSyncResp><hRet>0</hRet></OrderGatherSyncResp>";
		System.out.println(parseXml(respXml));
	}
}
